package com.sinbader.xiaole.admin.controller;

import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import com.sinbader.xiaole.common.entity.WarehouseMoveDetail;
import com.sinbader.xiaole.common.model.params.WarehouseMoveDetailParam;
import com.sinbader.xiaole.common.service.WarehouseMoveDetailService;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.kernel.model.response.ResponseData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;


/**
 * 仓库移货管理明细控制器
 *
 */
@Api("仓库移货管理明细")
@Controller
@RequestMapping("/warehouseMoveDetail")
public class WarehouseMoveDetailController extends BaseController {

    private String PREFIX = "/warehouseMoveDetail";

    @Autowired
    private WarehouseMoveDetailService warehouseMoveDetailService;

    /**
     * 跳转到主页面
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "/warehouseMoveDetail.html";
    }

    /**
     * 新增页面
     */
    @RequestMapping("/add")
    public String add() {
        return PREFIX + "/warehouseMoveDetail_add.html";
    }

    /**
     * 编辑页面
     */
    @RequestMapping("/edit")
    public String edit() {
        return PREFIX + "/warehouseMoveDetail_edit.html";
    }

    @ApiOperation(value = "新增")
    @RequestMapping("/addItem")
    @ResponseBody
    public ResponseData addItem(WarehouseMoveDetailParam warehouseMoveDetailParam) {
        this.warehouseMoveDetailService.add(warehouseMoveDetailParam);
        return ResponseData.success();
    }

    @ApiOperation(value = "编辑")
    @RequestMapping("/editItem")
    @ResponseBody
    public ResponseData editItem(WarehouseMoveDetailParam warehouseMoveDetailParam) {
        this.warehouseMoveDetailService.update(warehouseMoveDetailParam);
        return ResponseData.success();
    }

    @ApiOperation(value = "删除")
    @RequestMapping("/delete")
    @ResponseBody
    public ResponseData delete(WarehouseMoveDetailParam warehouseMoveDetailParam) {
        this.warehouseMoveDetailService.delete(warehouseMoveDetailParam);
        return ResponseData.success();
    }

    @ApiOperation(value = "查看详情")
    @RequestMapping("/detail")
    @ResponseBody
    public ResponseData detail(WarehouseMoveDetailParam warehouseMoveDetailParam) {
        WarehouseMoveDetail detail = this.warehouseMoveDetailService.getById(warehouseMoveDetailParam.getId());
        return ResponseData.success(detail);
    }

    @ApiOperation(value = "查询列表")
    @ResponseBody
    @RequestMapping("/list")
    public LayuiPageInfo list(WarehouseMoveDetailParam warehouseMoveDetailParam) {
        return this.warehouseMoveDetailService.findPageBySpec(warehouseMoveDetailParam);
    }

}
